import http from '@/service/axios'

/* 角色相关 */

// 添加角色
export const AddRole = role => http('POST', '/role/add', role)
// 修改角色
export const UpdateRole = role => http('PUT', '/role/update', role)
// 修改用户角色关系
export const UpdateUserRoleRelation = (userId, roleIdList) => http('PUT', '/role/relation/update', {
  userId,
  roleIdList
})
// 删除角色
export const DeleteRole = id => http('DELETE', '/role/delete', { id })
// 查询角色分页信息
export const GetRolePage = (name, page, size) => http('GET', '/role/page', {
  name,
  page,
  size
})
// 查询角色树
export const GetRoleTree = () => http('GET', '/role/tree')
// 查询用户对应的角色
export const GetUserRole = userId => http('GET', '/role/user', { userId })

/* 资源相关 */

// 添加资源
export const AddResources = resources => http('POST', '/resources/add', resources)
// 修改资源
export const UpdateResources = resources => http('PUT', '/resources/update', resources)
// 修改角色资源关系
export const UpdateRoleResourcesRelation = (roleId, resourcesIdList) => http('PUT', '/resources/relation/update', {
  roleId,
  resourcesIdList
})
// 删除资源
export const DeleteResources = id => http('DELETE', '/resources/delete', { id })
// 查询资源分页信息
export const GetResourcesPage = (name, url, type, page, size) => http('GET', '/resources/page', {
  name,
  url,
  type,
  page,
  size
})
// 查询资源详情
export const GetResourcesDetail = id => http('GET', '/resources/detail', { id })
// 查询资源树
export const GetResourcesTree = ignoreId => http('GET', '/resources/tree', { ignoreId })
// 查询角色对应的资源
export const GetRoleResources = roleId => http('GET', '/resources/role', { roleId })
